#pragma once
#include "RBTree.h"
namespace My
{
	template<class K,class V>
	class map
	{
	public:
		struct MyKeyOfV
		{
			const K& operator() (const pair<K,V>& kv)
			{
				return kv.first;
			}
		};
		typedef typename RBTree<K, pair<const K, V>, MyKeyOfV>::Iterator iterator;
		iterator begin()
		{
			return _t.Begin();
		}
		iterator end()
		{
			return _t.End();
		}

		void insert(const pair<K, V>& kv)
		{
			_t.Insert(kv);
		}



	private:
		RBTree<K, pair<const K,V>, MyKeyOfV> _t;
	};

	void test_Mymap()
	{
		map<string, int> m;
		m.insert({ "a", 1 });
		m.insert({ "b", 1 });
		m.insert({ "e", 1 });
		m.insert({ "c", 1 });
		m.insert({ "y", 1 });
		m.insert({ "j", 1 });
		map<string, int>::iterator it = m.begin();
		while (it != m.end())
		{
			it->second += 1;
			cout << it->first << ":" << it->second << endl;
			++it;
		}
		cout << endl;
	}
}